home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_099 / a-render / build_objects / bcube.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  4KB  |  141 lines

  1.  
  2. #include <stdio.h>
  3.  
  4. main()
  5. {
  6. FILE *fopen(), *fp;
  7.  
  8. int
  9.     polygon_id,
  10.     vertice_id,
  11.     vlist_id,
  12.     object_polygon_count,
  13.     object_vertice_count,
  14.     object_polygon_vertice_count[41],
  15.     object_vertice_list[41] [30];
  16.  
  17. float
  18.        object_vertice_x[41],
  19.        object_vertice_y[41],
  20.        object_vertice_z[41];
  21.  
  22.  
  23.  
  24.   object_polygon_count = 6;
  25.   object_vertice_count = 8;
  26.  
  27.  
  28.     object_vertice_x [1] = -10;
  29.     object_vertice_y [1] = -10;
  30.     object_vertice_z [1] = 10;
  31.  
  32.     object_vertice_x [2] = -10;
  33.     object_vertice_y [2] = 10;
  34.     object_vertice_z [2] = 10;
  35.  
  36.     object_vertice_x [3] = 10;
  37.     object_vertice_y [3] = 10;
  38.     object_vertice_z [3] = 10;
  39.  
  40.     object_vertice_x [4] = 10;
  41.     object_vertice_y [4] = -10;
  42.     object_vertice_z [4] = 10;
  43.  
  44.     object_vertice_x [5] = -10;
  45.     object_vertice_y [5] = -10;
  46.     object_vertice_z [5] = -10;
  47.  
  48.     object_vertice_x [6] = -10;
  49.     object_vertice_y [6] = 10;
  50.     object_vertice_z [6] = -10;
  51.  
  52.     object_vertice_x [7] = 10;
  53.     object_vertice_y [7] = 10;
  54.     object_vertice_z [7] = -10;
  55.  
  56.     object_vertice_x [8] = 10;
  57.     object_vertice_y [8] = -10;
  58.     object_vertice_z [8] = -10;
  59.  
  60.  
  61.       object_polygon_vertice_count [1] = 5;
  62.       object_vertice_list [1] [1] = 6;
  63.       object_vertice_list [1] [2] = 2;
  64.       object_vertice_list [1] [3] = 3;
  65.       object_vertice_list [1] [4] = 7;
  66.       object_vertice_list [1] [5] = 6;
  67.  
  68.       object_polygon_vertice_count [2] = 5;
  69.       object_vertice_list [2] [1] = 7;
  70.       object_vertice_list [2] [2] = 3;
  71.       object_vertice_list [2] [3] = 4;
  72.       object_vertice_list [2] [4] = 8;
  73.       object_vertice_list [2] [5] = 7;
  74.  
  75.       object_polygon_vertice_count [3] = 5;
  76.       object_vertice_list [3] [1] = 8;
  77.       object_vertice_list [3] [2] = 4;
  78.       object_vertice_list [3] [3] = 1;
  79.       object_vertice_list [3] [4] = 5;
  80.       object_vertice_list [3] [5] = 8;
  81.  
  82.       object_polygon_vertice_count [4] = 5;
  83.       object_vertice_list [4] [1] = 2;
  84.       object_vertice_list [4] [2] = 6;
  85.       object_vertice_list [4] [3] = 5;
  86.       object_vertice_list [4] [4] = 1;
  87.       object_vertice_list [4] [5] = 2;
  88.  
  89.       object_polygon_vertice_count [5] = 5;
  90.       object_vertice_list [5] [1] = 6;
  91.       object_vertice_list [5] [2] = 7;
  92.       object_vertice_list [5] [3] = 8;
  93.       object_vertice_list [5] [4] = 5;
  94.       object_vertice_list [5] [5] = 6;
  95.  
  96.       object_polygon_vertice_count [6] = 5;
  97.       object_vertice_list [6] [1] = 4;
  98.       object_vertice_list [6] [2] = 3;
  99.       object_vertice_list [6] [3] = 2;
  100.       object_vertice_list [6] [4] = 1;
  101.       object_vertice_list [6] [5] = 4;
  102.  
  103.  
  104.  
  105.       if ((fp = fopen("cube.obj","w")) == 0) {
  106.         printf("Couldn't open cube.obj file for write\n");
  107.         exit();
  108.       }
  109.           fprintf(fp,"1 1 3 %d %d",
  110.                   object_polygon_count,
  111.                   object_vertice_count);
  112.  
  113.       for (vertice_id=1;
  114.            vertice_id <= object_vertice_count; vertice_id++)
  115.             {
  116.             fprintf(fp," %f %f %f",
  117.                     object_vertice_x [vertice_id],
  118.                     object_vertice_y [vertice_id],
  119.                     object_vertice_z [vertice_id]);
  120.             }
  121.       for (polygon_id=1;
  122.            polygon_id <= object_polygon_count; polygon_id++)
  123.               {
  124.               fprintf(fp," %d",
  125.               object_polygon_vertice_count [polygon_id]);
  126.  
  127.       for (vlist_id=1;
  128.        vlist_id <= object_polygon_vertice_count [polygon_id];
  129.         vlist_id++)
  130.                 {
  131.                 fprintf(fp," %d",
  132.                 object_vertice_list [polygon_id] [vlist_id]);
  133.                 }
  134.               }
  135.  
  136.       printf("objects.dta written\n");
  137.       fclose(fp);
  138. printf("closed\n");
  139. }
  140.  
  141.